<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="tel" class="layui-input"  placeholder="请输入联系电话" value="{$row.tel|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">五星评价</label>
            <div class="layui-input-block">
                <input type="text" name="scores" class="layui-input"  placeholder="请输入五星评价" value="{$row.scores|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">图片/视频 以 | 做分割符号</label>
            <div class="layui-input-block layuimini-upload">
                <input name="images" class="layui-input layui-col-xs6"   placeholder="请上传图片/视频" value="{$row.images|default=''}">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="images" data-upload-number="more" data-upload-exts="png|jpg|ico|jpeg" data-upload-icon="image"><i class="fa fa-upload"></i> 上传</a></span>
                    <span><a class="layui-btn layui-btn-normal" id="select_images" data-upload-select="images" data-upload-number="more" data-upload-mimetype="image/*"><i class="fa fa-list"></i> 选择</a></span>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
<!--            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">-->
<!--                <legend>上传视频</legend>-->
<!--            </fieldset>-->
            <label class="layui-form-label required">上传视频</label>
<!--            <div class="layui-form-item">-->
                <div class="layui-input-block layuimini-upload">
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                    <button type="button" class="layui-btn cover" id="control_video_button"><i class="layui-icon">&#xe6ed;</i>视频上传</button>
                    <button type="button" class="layui-btn layui-btn-danger cover" id="control_video_del" style="display: inline"><i class="layui-icon">&#xe640;</i>删除视频</button>
                    <input type="hidden" id="control_video" value="" name="control_video"/>
                    <input type="hidden" id="temp_url_id" value="" name="temp_url_id"/>
                </blockquote>
            </div>

            <div class="layui-form-item" style="display: none;">
                <label for="H_img" class="layui-form-label ">
                    URL
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="H_img"   name="images"  autocomplete="off" class="layui-input" style="display: none;">
                </div>
            </div>
            <div class="layui-form-item" style="display: none;">
                <label for="H_video" class="layui-form-label ">
                    URL
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="H_video"   name="video"  autocomplete="off" class="layui-input" style="display: none;">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否匿名</label>
            <div class="layui-input-block">
                <input type="radio" name="isanonymous" lay-skin="primary"   value="1" title="是" {if $row.isanonymous eq 1}checked="" {/if}>
                <input type="radio" name="isanonymous" lay-skin="primary"   value="2" title="否" {if $row.isanonymous eq 2}checked="" {/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">评价内容</label>
            <div class="layui-input-block">
                <textarea name="content" rows="20" class="layui-textarea editor" 评价内容 placeholder="请输入评价内容">{$row.content|raw|default=''}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属管理员</label>
            <div class="layui-input-block">
                <input type="text" name="admin_id" class="layui-input"  placeholder="请输入所属管理员" value="{$row.admin_id|default=''}">
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script>
    //单击图片删除图片 【注册全局函数】
    function delThis(this_img){
        var multiple_images_string = document.getElementById("picText_2").value;
        var multiple_images = multiple_images_string.split(",");
        //获取下标
        var subscript=$("#upload_list img").index(this_img);
        //删除图片
        this_img.remove();
        //删除数组
        multiple_images.splice(subscript, 1);
        //重新排序
        multiple_images.sort();
        document.getElementById("picText_2").value = multiple_images;
        //返回
        return ;
    }
    layui.use(['upload','form', 'layer', 'laydate'], function() {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form
            , layer = layui.layer
        //多图片上传
        var uploadInst2 = upload.render({
            elem: '#upload_2'
            , url: '/admin/evaluation.elist/uploadVideo' //多图上传接口
            , multiple: true
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload_list').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" style="width: 140px;height: 100px;" οnclick="delThis(this)">')
                });
            }
            , done: function (data) {
                //上传失败
                if (data.code > 0) {
                    return layer.msg('上传失败');
                } else {
                    //上传成功
                    var last_url = document.getElementById("picText_2").value;
                    var upload_url = "";
                    if (last_url !== "") {
                        upload_url = last_url + "," + data.filename;
                    } else {
                        upload_url = data.filename;
                    }
                    document.getElementById("picText_2").value = upload_url;
                    //将后台获取的图片地址传到前台存入隐藏控件中，随着表单一起提交
                    console.log(upload_url);
                    document.getElementById("H_img").value = upload_url;
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText2 = $('#demoText2');
                demoText2.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText2.find('.demo-reload').on('click', function () {
                    uploadInst2.upload();
                });
            }
        });
        //视频上传
        var uploadInst = upload.render({
            elem: '#control_video_button', //绑定元素
            url: "/admin/evaluation.elist/uploadVideo",//上传接口
            accept: 'video'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#control_video_demo').attr('src', result); //图片链接（base64）
                    $('#control_video_demo').css('display', 'block');
                    $('#control_video_del').css('display', 'inline');
                });
            },
            done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                // console.log(res.data.src);return false;
                //上传成功
                filename = res.data.src;
                document.getElementById("control_video").value = filename;
                document.getElementById("H_video").value = filename;

            }, error: function (res) {
                console.log(res);
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        //删除视频
        $('#control_video_del').click(function () {
            $('#control_video_demo').css('display', 'none');
            $('#control_video_del').css('display', 'none');
            $('#control_video').val('');
            document.getElementById("H_video").value = "";
        })
    });
</script>